/*
 * @Author: Mr.Cong Wei
 * @Date: 2022-07-26 22:12:43
 * @LastEditTime: 2022-07-26 22:17:25
 */

const axios = require('./request')
const { convertHtml } = require('./convertHtml')
const { bookUrl } = require('./setting')
const saveFs = require('./saveFs')
const getData = async () => {
    try {
        const res = await axios.get(bookUrl)
        //格式化文件
        const { title, list } = convertHtml(res.data)
        // 保存文件
        saveFs(title, list)
    } catch (err) {
        console.log('\n下载失败，出现网络错误，正在重新尝试...')
        return getData()
    }
}
module.exports = getData
